#include "../../client/rpc_client.hpp"

void callBack(const std::string& key, const std::string& msg)
{
    LOG(DEBUGLEVEL, "收到 %s 发来的消息 -- %s ", key.c_str(), msg.c_str());
}

int main()
{
    MyRpc::client::TopicClinent::ptr subscribe_topic = std::make_shared<MyRpc::client::TopicClinent>("127.0.0.1", 8888);
    // 创建主题
    bool flag = subscribe_topic->create("music");
    if(flag == false)
    {
        LOG(DEBUGLEVEL, "创建主题失败!");
    }

    flag = subscribe_topic->subscribe("music", callBack);
    if(flag == false)
    {
        LOG(DEBUGLEVEL, "订阅主题失败!");
    }

    std::this_thread::sleep_for(std::chrono::seconds(10));
    subscribe_topic->shutDown();
    return 0;
}